<?php
	//echo "<" . sizeof($server->listItemsOnShoppingList());
	$doc = new DOMDocument();
	$doc->formatOutput = true;

	$shoppingList = $doc->createElement( "shoppingList" );
	$doc->appendChild( $shoppingList );
	
	foreach ($server->listItemsOnShoppingList() as $item){
		$shoppingListItem = $doc->createElement( "shoppingListItem" );
		
		$productName = $doc->createElement( "productName" );
		$productName->appendChild($doc->createTextNode( $item[0] ));
		$packageName = $doc->createElement( "packageName" );
		$packageName->appendChild($doc->createTextNode( $item[1] ));
		$metricSystemUnitName = $doc->createElement( "metricSystemUnitName" );
		$metricSystemUnitName->appendChild($doc->createTextNode( $item[2] ));
		$quantity = $doc->createElement( "quantity" );
		$quantity->appendChild($doc->createTextNode( $item[3] ));
		$amountAvailable = $doc->createElement( "amountAvailable" );
		$amountAvailable->appendChild($doc->createTextNode( $item[4] ));
		$amountDesired = $doc->createElement( "amountDesired" );
		$amountDesired->appendChild($doc->createTextNode( $item[5] ));
		
		$shoppingListItem->appendChild($productName);
		$shoppingListItem->appendChild($packageName);
		$shoppingListItem->appendChild($metricSystemUnitName);
		$shoppingListItem->appendChild($quantity);
		$shoppingListItem->appendChild($amountAvailable);
		$shoppingListItem->appendChild($amountDesired);
		
		$shoppingList->appendChild($shoppingListItem);
	}
	
	echo $doc->saveXML();
?>